<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hope2</title>
    <link rel="stylesheet" href="https://lib.baomitu.com/bulma/0.9.1/css/bulma.css">
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.datatables.net/rss.xml">
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.min.css">
    <script type="text/javascript" language="javascript"
            src="https://lib.baomitu.com/jquery/3.5.1/jquery.min.js"></script>
    <script type="text/javascript" language="javascript"
            src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript">
        var link = `/analysis/intersection-report?`;
        // var link = 'http://127.0.0.1:8003/analysis/intersection-report?';
        var table;
        $(document).ready(function () {
            table = $('#stockTable').DataTable({
                columns: [
                    {
                        data: 'code',
                        render: function (data, type, row, meta) {
                            return type === 'display' ?
                                `<a href="${row.url}" target="_blank">${data}</a>` :
                                // '<a href="' + row.url + '">'+data+'</a>' :
                                data;
                        }
                    },
                    {data: 'name'},
                    {
                        data: 'setup',
                        render: function (data, type, row, meta) {
                            var flags = row.data.flag;
                            if (flags == null || flags.length == 0) {
                                return '';
                            } else {
                                return flags[flags.length - 1].setupDate;
                            }
                        }
                    },
                    {
                        data: 'countdown',
                        render: function (data, type, row, meta) {
                            var flags = row.data.flag;
                            if (flags == null || flags.length == 0) {
                                return '';
                            } else {
                                if (flags[flags.length - 1].countdownDate != null) {
                                    return flags[flags.length - 1].countdownDate;
                                } else {
                                    for (let i = flags.length - 2; i >= 0; i--) {
                                        if (flags[i].countdownDate != null) {
                                            return flags[i].countdownDate;
                                        }
                                    }
                                    return "";
                                }
                            }
                        }
                    },
                    {data: 'value'},
                    {
                        data: 'code',
                        render: function (data, type, row, meta) {
                            var code = row.code;
                            return type === 'display' ?
                                `<a href="/demark-flag.html?code=${code}" target="_blank">图形版</a>` + '&nbsp;&nbsp;&nbsp;&nbsp;    ' +
                                `<a href="/demark-flag-advance.html?code=${code}" target="_blank">高级版</a>` :
                                data;
                        }
                    }
                ]
            });
            post();
        });

        function post() {
            var selected = $('input:checkbox:checked');
            var str = "";
            selected.each(function () {
                str += "report=" + $(this).val() + "&";
            });
            str += "secret=4587";
            var linkNew = link + str;
            getData(linkNew);
        }

        function getData(link) {
            $.getJSON(link, function (data) {
                table.clear().rows.add(data.resultList).draw();
            });
        }


    </script>
</head>
<body class="layout-default">
<nav id="navbar" class="bd-navbar navbar has-shadow is-spaced">
    <div class="container">
        <div class="navbar-brand">
            <a class="navbar-item" href="https://qianyitian.com/">
                <img style="height:36px;width:36px;" src="https://img.qianyitian.com/icon/logo.png">  <h4
                    class="title is-3">Hope2</h4>
            </a>
        </div>
    </div>
</nav>

<section class="section">
    <div class="container">
        <div class="columns">
            <div class="column is-1">
            </div>
            <div class="column is-3">
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input value="FiveFive-daily" type="checkbox" checked=“checked”>
                                近日常阳
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input value="MACDSquare-weekly" type="checkbox" checked=“checked”>
                                MACD阴影面积
                            </label>
                        </div>
                    </div>
                </div>

                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input value="SuddentIncrease-daily" type="checkbox">
                                近日涨停
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input value="Demark-weekly" type="checkbox">
                                Demark周线买点
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="column is-1">
            </div>
            <div class="column is-3">
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input value="WeekVolume-weekly" type="checkbox" checked=“checked”>
                                周线暴量
                            </label>
                        </div>
                    </div>
                </div>

                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input value="YesterdayOnceMore-daily" type="checkbox">
                                昨日重现
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input value="USMACD-weekly" type="checkbox">
                                美股MACD
                            </label>
                        </div>
                    </div>
                </div>
                <div class="field-body">
                    <div class="field">
                        <div class="control">
                            <label class="checkbox">
                                <input value="USKDJ-daily" type="checkbox">
                                美股KDJ
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="column is-1">
            </div>
            <div class="column is-3">
                <div class="field-body">
                    <div class="field is-grouped">
                        <div class="control">
                            <button class="button is-link" onclick="post()">Submit</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<section class="section">
    <div class="container">
        <table id="stockTable" class="display compact" style="width:100%">
            <thead>
            <tr>
                <th>代码</th>
                <th>名称</th>
                <th>最近的BS</th>
                <th>最近的BC</th>
                <th>参考值</th>
                <th>历史回溯</th>
            </tr>
            </thead>
        </table>
    </div>
</section>
<hr>
</body>
</html>